package stu.wingsmaker.artofsubway.model.adapter;

import stu.wingsmaker.artofsubway.R;
import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

public class CulturePlaceListCursorAdapter extends CursorAdapter {

	public CulturePlaceListCursorAdapter(Context context, Cursor c) {
		super(context, c);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void bindView(View root, Context context, Cursor cursor) {
	//	((TextView) root).findViewById(R.id.culturePlace);
		// TODO Auto-generated method stub
		ImageView placeImg = (ImageView) root.findViewById(R.id.cultureImage);
		TextView placeNameTv = (TextView) root.findViewById(R.id.culturePlace);
		TextView placeSubwayTv = (TextView) root.findViewById(R.id.culturePlaceSubway);
		
		
		placeNameTv.setText(cursor.getString(cursor.getColumnIndex(cursor.getColumnName(1))));
	    placeSubwayTv.setText(cursor.getString(cursor.getColumnIndex(cursor.getColumnName(2))));
	    System.out.println(cursor.getColumnName(1).toString());
	    System.out.println(cursor.getString(1));
	    
	   
	    if(cursor.getString(1).equals("서울시립미술관")) {
	    	placeImg.setImageResource(R.drawable.artcenter);
	    } else if(cursor.getString(1).equals("경복궁")){
	    	placeImg.setImageResource(R.drawable.kyeongbokgoong);
	    } else if(cursor.getString(1).equals("서울역사박물관")){
	    	
	    } else if(cursor.getString(1).equals("국립중앙박물관")) {
	    	
	    }
	    

	}

	@Override
	public View newView(Context context, Cursor cursor, ViewGroup parent) {
		// TODO Auto-generated method stub
		LayoutInflater inflater = LayoutInflater.from(parent.getContext());
		View root = inflater.inflate(R.layout.culture_listview, parent, false);
		return root;
	}

}
